<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <title>登入 - 啄木鸟</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta
                name="viewport"
                content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
        >
        <!--<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">-->
        <!--<script th:src="${SYS_RES}+'/static/lay/layui/layui.min.js'"></script>-->
    </head>
    <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script>
    <body>
        <p>已在外部浏览器打开</p>
    </body>
    <script>
        let env = "[[${ZMN_URL_ENV}]]";
        var json = {};
        json.authCode = "[[${authCode}]]";
        json.corpId = "[[${corpId}]]";
        json.cubeFlag = "[[${cubeFlag}]]";
        if (json.authCode == null || json.authCode == undefined || json.authCode == "") {
            dd.ready(function() {
                dd.runtime.permission.requestAuthCode({
                    corpId: json.corpId, // 企业id
                    onSuccess: function (info) {
                        var code = info.code; // 通过该免登授权码可以获取用户身份
                        var url = env + 'mcc.xiujiadian.com/authCodeLogin.action?authCode=' + code;
                        if (json.cubeFlag != null && json.cubeFlag != "") {
                            url = url + "&cubeFlag=" + json.cubeFlag;
                        }
                        dd.biz.util.openLink({
                            url:url,//要打开链接的地址
                            onSuccess : function(result) {

                            },
                            onFail : function(err1) {
                                alert("跳转报错," + err1);
                            }
                        });
                    },
                    onFail: function (err) {
                        alert("错误，" + err);
                    }
                });
            });



            dd.error(function(err) {
                alert('dd error: ' + JSON.stringify(err));
            });
        } else {
            var locateUrl = env + 'mcc.xiujiadian.com/jumpLogin.action?authCode=' + json.authCode;
            if (json.cubeFlag != null && json.cubeFlag != "") {
                locateUrl = locateUrl + "&cubeFlag=" + json.cubeFlag;
            }
            window.location.href = locateUrl;
        }
    </script>
</html>